package com.graduation.project.handler;

import com.graduation.project.enums.ResultCodeEnum;
import com.graduation.project.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 卑微小峰
 * @date 2022/10/29
 * 全局异常处理类
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class )
    public ResultUtil<?> handlerException(Exception e){
        log.info("数据校验异常：{}", e.getMessage());
        return ResultUtil.Failed(ResultCodeEnum.FILED.getCode(), e.getMessage());
    }
}
